package com.ask.forMe.controller.business;

import com.ask.forMe.model.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/kafka")
public class KafkaController {
    @Autowired
    private KafkaTemplate kafkaTemplate;
    @PostMapping
    public Result sendMessage() {
        String message = "hello kafka";
        kafkaTemplate.send("topic1" ,message);
        return Result.success("send success");
    }
}
